import {
  get,
  postParam
} from "../../utils/service"
import Dialog from '../../miniprogram_npm/@vant/weapp/dialog/dialog'

var app = getApp()

Page({
  data: {
    userInfo: null
  },
  onLogout: function () {
    Dialog.confirm({
        title: '确认',
        message: '确定退出登录吗?',
      })
      .then(() => {
        postParam(`${app.globalData.host}/user/logout`, {}, {
          success: function () {
            app.globalData.userInfo = null
            wx.navigateTo({
              url: '/pages/home/home',
            })
          }
        })
      })
      .catch(() => {});
  },
  onLoad: function (options) {
    this.setData({
      userInfo: app.globalData.userInfo
    })
  }
});